package com.woniuxy.config;

import com.woniuxy.utils.MailUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Created by xxhcm on 2021/3/24.
 */
@RabbitListener(queues
        = {"mailQueue","codeQueue"})
//@Component
@SuppressWarnings("all")
public class AmqpRecieve {
    @Autowired
    private JavaMailSender mailSender;
    @RabbitHandler
    public void recieve(String account){
        MailUtil.SendMail(account,mailSender);
    }
    @RabbitHandler
    public void reciecve(Map<String,String>map){
        String account = "";
        String content = "";
        for(String accounts : map.keySet()){
            account = accounts ;
            content = map.get(accounts);
        }
        MailUtil.sendCode(account,mailSender,content);
    }
}
